package com.mrdeer.user.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Configuration;

/**
 * 惰性初始化-加快SpringBoot
 *
 * @author ：xie jianchu
 * @date ：Created in 2020/9/7 0007 17:22
 */
@Configuration
public class LazyInitBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        for (String beanName : configurableListableBeanFactory.getBeanDefinitionNames()) {
            configurableListableBeanFactory.getBeanDefinition(beanName).setLazyInit(true);
        }
    }
}
